//https://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106?tpId=13&&tqId=11174&rp=1&ru=/activity/oj&qru=/ta/coding-interviews/question-ranking

class Solution {
public:
    bool IsPopOrder(vector<int>& pushV, vector<int>& popV) {
        int pushptr = 0, popptr = 0;
        stack<int> st;

        while (pushptr < pushV.size())
        {
            st.push(pushV[pushptr++]);
            //出栈
            while (!st.empty() && popV[popptr] == st.top())
            {
                st.pop();
                popptr++;
            }
        }

        return st.empty();

    }
};